package com.example.myfirstapp;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends Activity {

	public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
	ImageButton button1; 
	ImageButton button2;
	ImageView image1;
	ImageView image2;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        addButtonListeners();
        
    }

    private void addButtonListeners() {
		image1 = (ImageView) findViewById(R.id.image_viewer);
		image2 = (ImageView) findViewById(R.id.image_viewer);
		
		button1 = (ImageButton) findViewById(R.id.button1);
		button2 = (ImageButton) findViewById(R.id.button2);
		
		button1.setOnClickListener(new OnClickListener(){
			
			@Override
			public void onClick(View arg0){
				
				Context context = getApplicationContext();
				CharSequence text = "You pressed button 1!";
				int duration = Toast.LENGTH_SHORT;
				Toast toast = Toast.makeText(context, text, duration);
				toast.show();
				
				image1.setImageResource(R.drawable.image1);
			}
			
		});
		
		button2.setOnClickListener(new OnClickListener(){
			
			@Override
			public void onClick(View arg0){
				
				Context context = getApplicationContext();
				CharSequence text = "You pressed button 2!";
				int duration = Toast.LENGTH_SHORT;
				Toast toast = Toast.makeText(context, text, duration);
				toast.show();
				
				image2.setImageResource(R.drawable.image2);
			}
		});
	}

	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
}
